package main

import (
	"demo/container"
	"fmt"
	"strconv"
)

func modifyArr(a [3]int) {
	a[0] = 10
}

func modifyArr2(a [3][2]int) {
	a[2][1] = 10
}

func array() {
	container.TestArray()

	a := [3]int{}
	modifyArr(a)
	fmt.Println(a)

	var b [3][2]int
	modifyArr2(b)
	fmt.Println(b)

	a = [3]int{1, 2, 4}
	aSlice := a[:]

	fmt.Printf("%p %p\n", &a, &aSlice)

	sum := container.SumArr(aSlice)
	fmt.Println("sum=" + strconv.Itoa(sum))

	slice := []int{1, 2, 3, 4, 5, 6, 7, 8}
	fmt.Println(container.FindResultIndex(slice, 8))
}

func slice() {
	container.TestSlice()

	a := []int{1, 2, 3, 4, 5}
	a1 := container.Del(a, 0)
	fmt.Println(a)
	fmt.Println(a1)

	a1 = container.DelValue(a, 4)
	fmt.Println(a)
	fmt.Println(a1)

	container.Print1()

	s := []int{5, 4, 3, 2, 1}
	container.SortSlice(s)
	fmt.Println(s)
}

func main() {
	//array()

	//slice()

	d := make([]int, 2, 10)
	fmt.Println(d)
	//container.TestMap()
	a := []int{1, 2, 3}

	a1 := append(a[:0], a[1:]...)
	fmt.Println(a1)
	fmt.Println(a)

	var a2 = make([]int, 10)
	copy(a2, a1)
	fmt.Println(a2)

	a2 = append(a2, 5, 6)
	fmt.Println(a2)

	b := []int{1, 2, 3, 4}
	b1 := append(b[:1], b[3:]...)

	fmt.Println(b)
	fmt.Println(b1)
}
